<?php
/**
 * Created by PhpStorm.
 * User: zhangxinke
 * Date: 2019/6/6
 * Time: 3:10
 */
namespace app\shop\controller;

use app\shop\model\TaobaoOrderModel;

class TaobaoOrder extends BaseController
{
    public function __construct()
    {
        parent::__construct();
        $this->taobaoorder = new TaobaoOrderModel();
    }
    //订单列表
    public function index()
    {
        $condition = 'o.status != 4 and o.status != 5 and o.status != 6 and o.status != 7';
        $orderList = $this->taobaoorder->getOrderList($condition);
        $this->assign('page',$orderList->render());
        $this->assign('orderList',$orderList);
        return view('taobaoorder/index');
    }
    //申诉订单
    public function refund()
    {
        $condition = 'o.status = 4 or o.status = 5 or o.status = 6';
        $orderList = $this->taobaoorder->refund($condition);
        $this->assign('page',$orderList->render());
        $this->assign('orderList',$orderList);
        return view('taobaoorder/refund');
    }
    //订单编辑
    public function orderEdit()
    {
        $orderInfo = $this->taobaoorder->orderEdit();
        if(request()->isAjax()){
            return $orderInfo;
        }else{
            $this->assign('orderInfo',$orderInfo);
            return view('taobaoorder/edit');
        }

    }
    //订单发货
    public function ordersend(){
        if(input('post.')){
            $result = $this->taobaoorder->ordersend();
            return $result;
        }else{
            $id = input('id');
            $this->assign('id', $id);
            return  view('taobaoorder/ordersend');
        }
    }
    //订单删除
    public function orderDel()
    {
        $result = $this->orderModel->orderDel();
        return $result;
    }
    //申诉页面
    public function show()
    {
        $condition = 'o.status = 4';
        $orderList = $this->taobaoorder->isrefund($condition);
        $this->assign('page',$orderList->render());
        $this->assign('orderList',$orderList);
        return view('taobaoorder/show');
    }
    //退款原因
    public function ordershow()
    {
        $ordershow = $this->taobaoorder->ordershow();
        $ordershow['img'] = explode(',',$ordershow['img']);
        $this->assign('ordershow',$ordershow);
        return view('taobaoorder/ordershow');
    }
    //修改状态
    public function status(){
        $res = $this->taobaoorder->status(input());
        return $res;
    }
}